package com.liuqi.knet.remoting;

import java.net.InetSocketAddress;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;

/**
 * 服务端配置项
 *
 * @author liuqi
 * @date 2025/2/8 16:52
 **/
@Getter
@Setter
@ToString
public class ServerConfig extends KNetConfig {

    /**
     * 本地绑定地址
     */
    private InetSocketAddress localAddress;

    /**
     * 服务端最大连接数, 0 表示不限制
     */
    private int accepts = 0;

    public ServerConfig(InetSocketAddress localAddress) {
        this.localAddress = localAddress;
    }

    public ServerConfig(InetSocketAddress localAddress, int accepts) {
        this.localAddress = localAddress;
        this.setAccepts(accepts);
    }

    public void setAccepts(int accepts) {
        if (accepts < 0) {
            throw new IllegalArgumentException("accepts < 0");
        }
        this.accepts = accepts;
    }

}
